import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GoodsSpecVO, GoodsSpecForm, GoodsSpecQuery } from '@/api/goods/goodsSpec/types';

/**
 * 查询商品规格列表
 * @param query
 * @returns {*}
 */

export const listGoodsSpec = (query?: GoodsSpecQuery): AxiosPromise<GoodsSpecVO[]> => {
    return request({
        url: '/order/goodsSpec/list',
        method: 'get',
        params: query
    });
};

/**
 * 查询商品规格详细
 * @param id
 */
export const getGoodsSpec = (id: string | number): AxiosPromise<GoodsSpecVO> => {
    return request({
        url: '/order/goodsSpec/' + id,
        method: 'get'
    });
};

/**
 * 新增商品规格
 * @param data
 */
export const addGoodsSpec = (data: GoodsSpecForm) => {
    return request({
        url: '/order/goodsSpec',
        method: 'post',
        data: data
    });
};

/**
 * 修改商品规格
 * @param data
 */
export const updateGoodsSpec = (data: GoodsSpecForm) => {
    return request({
        url: '/order/goodsSpec',
        method: 'put',
        data: data
    });
};

/**
 * 删除商品规格
 * @param id
 */
export const delGoodsSpec = (id: string | number | Array<string | number>) => {
    return request({
        url: '/order/goodsSpec/' + id,
        method: 'delete'
    });
};